# -*- coding: utf-8 -*-

#This file is part of pyLot library.
#
# pyLot is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyLot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with pyLot.  If not, see <http://www.gnu.org/licenses/>.

__author__ = u'Pierre Puiseux, Guillaume Baty'
__copyright__ = u"Copyright 2011-2012 (C) andheo, Université de Pau et des Pays de l'Adour"
__credits__ = [u'Pierre Puiseux', u'Guillaume Baty']
__license__ = "GNU Lesser General Public License"

__all__ = ['CollectionRepr', 'ContainerRepr']

from traits.api import  implements
from pyLot.dataconverter import IDataRepr

from _pylot.legacy.collection import Collection
from pyLot.core import Container

class CollectionRepr(Collection):
  identifier = 'pyLot.repr.collection'
  implements(IDataRepr)
  example_python = """
  """

  def new(self):
    return CollectionRepr()

  def sample(self):
    from _pylot.legacy.book import Book
    from pyLot.core import Datum
    book1 = Book(Datum(u'i', int, 1), title=u'Livre1')
    c = Collection(book1, name=u'collec')
    c.setValue(u'Livre1', u'i', 3)
    return c

  def toPyCode(self):
    return repr(self)

  def copy(self):
    import copy
    return copy.copy(self)

class ContainerRepr(Container):
  identifier = 'pyLot.repr.container'
  implements(IDataRepr)
  example_python = """
  """

  def new(self):
    return ContainerRepr()
